import axios from './axios';

export function http_p(prom: any) {
    return new Promise(function (resolve, reject) {
        prom.then((res: any) => {
            let content = res.data;
            resolve(content);
        }).catch((err: any) => {
            reject(err);
        });
    });
}
export function http_post(args: any, url = '/') {
    // 以form-data形式传参
    // let params = josnToFormData(args);
    // headers: { 'Content-Type': 'application/form-data' },
    // headers: { 'Content-Type': 'application/json' },
    return http_p(axios({ url: url, method: 'post', data: args }));
}

export function http_get(args: any, url = '/') {
    return http_p(axios({ url: url, method: 'get', params: args }));
}
